package com.wang.dao;

import com.wang.entity.User;
import com.wang.util.JdbcUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 注册dao
 */
public class FindUser {
    private JdbcUtil util = new JdbcUtil();
    List<Integer> userList = new ArrayList<>();
    public  Boolean findExist(User user){
        String sql = "select id,username,password,auth from user where username = ? and password = ?";
        PreparedStatement ps = util.createStatement(sql);
        boolean Result = false;
        int result = 0;
        try {
            ps.setString(1,user.getName());
            ps.setString(2,user.getPassword());
            ResultSet resultSet = ps.executeQuery();
            while (resultSet.next()){
                userList.add(1);
            }
            if (userList.size()>0){
                Result = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            util.close();
            return Result;
        }
    }

}
